<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>人物管理系统</title>
		<link th:href="@{/css/page.css}" rel="stylesheet" type="text/css" />
		<link th:href="@{/css/css_admin.css}" rel="stylesheet" type="text/css" />
		<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
		<script type="text/javascript" th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/util.js}"></script>
		<style>
			.tab1{border:1px solid #ddd}
			.tab1 td{border:1px solid #ddd}
			.tab1 th{border:1px solid #ddd}
			.tab1 .input2{height:24px; line-height:24px; border:1px solid #ddd; background:#f5f5f5; padding:0 5px; width:200px}
		</style>
</head>
<body>
  <div id="content_add" class="content_top" align="center">
  	<form>  	
  		<input type="hidden" name="id" id="id" th:value="${role.id}"/>	
  		<table border="0" cellpadding="0" cellspacing="1" class="tab1" align="left" text-align="left">
   			<tr style="height:30px">
   				<td class="td_add_1" align="right" style="width:150px">角色编码:</td>
   				<td class="td_add_2" align="left">
   					<input type="text" id="rolename" name="rolename" th:value="${role.rolename}"  maxlength="15" class="inp1"/>
			  		<font color="red">*</font>必填。角色命名为YY_YS_0000X格式，例如：YY_YS_00001表示“管理员”，YY_YS_00002表示“普通用户”。
   				</td>
   			</tr>
   			<tr style="height:30px">
   				<td class="td_add_1" align="right">角色描述:</td>
   				<td class="td_add_2" align="left">
   					<input type="text" id="memo" name="memo" th:value="${role.memo}" class="inp1" />
   				</td>
   			</tr>
   			<!-- <tr style="height:30px">
   				<td class="td_add_1" align="right">权限:</td>
   				<td class="td_add_2" align="left" id="powers" style="padding-bottom:5px">
   					<input type="checkbox" name="allCheck" id="allCheck" onclick="selectCheckbox('allCheck','power')" ><label for="allCheck"> 全选</label>
           			<br/>
           			设置变量一级分类catalog1，二级分类catalog2，后面的权限和前面的相同时，聚在一块
           			<c:set value="0" var="catalog1" />	
           			<c:set value="0" var="catalog2" />	
           			<table width="98%" border="0" align="left" cellpadding="0" cellspacing="1" class="tab2" style="text-align:left" >
						<tbody></tbody>
           				<tr>
           					<td style="text-align:center;font-size:14px;width:15%">一级分类</td>
           					<td style="text-align:center;font-size:14px;width:15%">二级分类</td>
           					<td style="text-align:center;font-size:14px;width:70%">权限		
		           				<c:forEach var="entity" items="${powers}" varStatus="varStatus">
		                			<c:if test="${entity.catalog1!=catalog1 && entity.catalog2!=catalog2 }">
		                				</td></tr>
		                				<tr><td valign="top" style="border-bottom:0px;">
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog1 eq item.id }">
												<input type="checkbox" name="power" id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog1}','catalog_${entity.catalog1}')" class="power" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog2 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog2}','catalog_${entity.catalog2}')" class="power catalog_${entity.catalog1}" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
									</c:if>
		
		                			<c:if test="${entity.catalog1==catalog1 && entity.catalog2!=catalog2 }">
		                				</td></tr><tr><td>
										&nbsp;</td><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog2 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog2}','catalog_${entity.catalog2}')" class="power catalog_${entity.catalog1}" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
									</c:if>
									
		                			<c:if test="${entity.catalog1!=catalog1 && entity.catalog2==catalog2 }">
		                				</td></tr><tr><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog1 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog1}','catalog_${entity.catalog1}')" class="power" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
										&nbsp;</td><td>
									</c:if>
									
									<input type="checkbox" name="power" class="power catalog_${entity.catalog1} catalog_${entity.catalog2}" id="power_${entity.id}" value="${entity.id}"
									 <c:forEach var="i" items="${myPowers}" varStatus="var">
									 	<c:if test="${i.powername eq entity.powername }">checked</c:if> 
									 </c:forEach> />
									 <label for="power_${entity.id}"><span title="权限编码:${entity.powername} 优先级:${entity.rank} 权限对应url:${entity.powerurl}">${entity.memo}</span></label>
									&nbsp;
		           					设置变量 一级分类catalog1，二级分类catalog2，后面的权限和前面的不同时，变量值修改
		           					<c:if test="${entity.catalog1 != catalog1 }">
		           						<c:set value="${entity.catalog1}" var="catalog1" />	
		           					</c:if>
		           					<c:if test="${entity.catalog2 != catalog2 }">
		           						<c:set value="${entity.catalog2}" var="catalog2" />	
		           					</c:if>
								</c:forEach>
							</td>
						</tr> 
           			</table>
           			<br/>
   				</td>
   			</tr>-->
   			<tr style="height:30px">
   				<td class="td_add_1" align="right">权限:</td>
   				<td class="td_add_2" align="left" id="powers" style="padding-bottom:5px">
   					<input type="checkbox" name="allCheck" id="allCheck" onclick="selectCheckbox('allCheck','power')" ><label for="allCheck"> 全选</label>
           			<br/>
           			设置变量一级分类catalog1，二级分类catalog2，后面的权限和前面的相同时，聚在一块
           			<c:set value="0" var="catalog1" />	
           			<c:set value="0" var="catalog2" />	
           			<table width="98%" border="0" align="left" cellpadding="0" cellspacing="1" class="tab2" style="text-align:left" >
						<tbody></tbody>
           				<tr>
           					<td style="text-align:center;font-size:14px;width:15%">一级分类</td>
           					<td style="text-align:center;font-size:14px;width:15%">二级分类</td>
           					<td style="text-align:center;font-size:14px;width:70%">权限		
		           				<c:forEach var="entity" items="${powers}" varStatus="varStatus">
		                			<c:if test="${entity.!= && entity.catalog2!=catalog2 }">
		                				</td></tr>
		                				<tr><td valign="top" style="border-bottom:0px;">
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity. eq item.id }">
												<input type="checkbox" name="power" id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog1}','catalog_${entity.catalog1}')" class="power" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										<span th:each="item,iterStat:${powerCatalogs}" >
										<input type="checkbox" name="power" id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog1}','catalog_${entity.catalog1}')" class="power" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
										</span>
										&nbsp;</td><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog2 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog2}','catalog_${entity.catalog2}')" class="power catalog_${entity.catalog1}" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
									</c:if>
		
		                			<c:if test="${entity.catalog1==catalog1 && entity.catalog2!=catalog2 }">
		                				</td></tr><tr><td>
										&nbsp;</td><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog2 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog2}','catalog_${entity.catalog2}')" class="power catalog_${entity.catalog1}" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
									</c:if>
									
		                			<c:if test="${entity.catalog1!=catalog1 && entity.catalog2==catalog2 }">
		                				</td></tr><tr><td>
		                				<c:forEach var="item" items="${powerCatalogs}" varStatus="varStatus">
											<c:if test="${entity.catalog1 eq item.id }">
												<input type="checkbox" name="power"  id="catalog_${item.id}" onclick="selectCheckbox('catalog_${entity.catalog1}','catalog_${entity.catalog1}')" class="power" value="" /><label for="catalog_${item.id}" class="catalog">${item.catalogname}</label>
											</c:if>
										</c:forEach>
										&nbsp;</td><td>
										&nbsp;</td><td>
									</c:if>
									
									<input type="checkbox" name="power" class="power catalog_${entity.catalog1} catalog_${entity.catalog2}" id="power_${entity.id}" value="${entity.id}"
									 <c:forEach var="i" items="${myPowers}" varStatus="var">
									 	<c:if test="${i.powername eq entity.powername }">checked</c:if> 
									 </c:forEach> />
									 <label for="power_${entity.id}"><span title="权限编码:${entity.powername} 优先级:${entity.rank} 权限对应url:${entity.powerurl}">${entity.memo}</span></label>
									&nbsp;
		           					设置变量 一级分类catalog1，二级分类catalog2，后面的权限和前面的不同时，变量值修改
		           					<c:if test="${entity.catalog1 != catalog1 }">
		           						<c:set value="${entity.catalog1}" var="catalog1" />	
		           					</c:if>
		           					<c:if test="${entity.catalog2 != catalog2 }">
		           						<c:set value="${entity.catalog2}" var="catalog2" />	
		           					</c:if>
								</c:forEach>
							</td>
						</tr> 
           			</table>
           			<br/>
   				</td>
   			</tr>
   			<tr style="height:50px">
   				<td colspan="2">
					<button type="button" class="btn btn-success  btn-sm"  style="width:80px" onClick="addOrUpdateRole()">确定</button> &nbsp; &nbsp;
					<button type="reset" class="btn btn-default  btn-sm"  style="width:80px" >重置</button>
   				</td>
   			</tr>
		</table>
	</form>
  </div>
</body>
</html>